from typing import Dict, Any, Optional
from pydantic import BaseModel
from enum import Enum


class EventType(str, Enum):
    """流处理智能体的事件类型"""
    APPROACH = "approach"
    THINKING_START = "thinking_start"
    THINKING = "thinking"
    ACTION_PLANNED = "action_planned"
    ACTION_START = "action_start"
    ACTION_RESULT = "action_result"
    OBSERVATION = "observation"
    PLAN_START = "plan_start"
    PLAN_CREATED = "plan_created"
    PLAN_STEP_START = "plan_step_start"
    PLAN_STEP_COMPLETE = "plan_step_complete"
    REPLAN_START = "replan_start"
    REFLECTION_START = "reflection_start"
    REFLECTION_CRITIQUE = "reflection_critique"
    REFLECTION_REFINEMENT = "reflection_refinement"
    REFLECTION_COMPLETE = "reflection_complete"
    FINISH = "finish"
    ERROR = "error"
    COMPLETE = "complete"


class StreamingEvent(BaseModel):
    """流处理智能体发出的事件结构定义"""
    type: EventType
    data: Dict[str, Any]
    timestamp: float
    step: int
    metadata: Optional[Dict[str, Any]] = None